//
//  BrandViewController.m
//  mhome
//
//  Created by 刘春雷 on 2018/11/26.
//  Copyright © 2018年 刘春雷. All rights reserved.
//

#import "BrandViewController.h"
#import "ProductDetailsViewController.h"
#import "UIImage+LX.h"

@interface BrandViewController ()<UITableViewDelegate,UITableViewDataSource>
    
@property (nonatomic,strong)UITableView *tableView;
@property (nonatomic,strong)NSArray *array;
@property (nonatomic,copy)NSArray *amyArray;
@property (nonatomic,copy)NSArray *caesarArray;
@property (nonatomic,copy)NSArray *SOHOArray;
@property (nonatomic,copy)NSArray *allArray;

@end

@implementation BrandViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"品牌";
    self.array = @[@"艾美",@"凯撒",@"SOHO"];
    self.tableView = [[UITableView alloc]initWithFrame:[UIScreen mainScreen].bounds style:UITableViewStyleGrouped];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.view addSubview:self.tableView];
    self.amyArray = @[@"http://www.mhome.com/assets/img/goods/aimei/aimei-canting.jpg",@"http://www.mhome.com//assets/img/goods/aimei/aimei-zhuwo.jpg",@"http://www.mhome.com/assets/img/goods/aimei/aimei-ciwo.jpg",@"http://www.mhome.com/assets/img/goods/aimei/aimei-ertongfang.jpg",@"http://www.mhome.com/assets/img/goods/aimei/aimei-keting.jpg",@"http://www.mhome.com/assets/img/goods/aimei/aimei-shufang.jpg",@"http://www.mhome.com/assets/img/goods/aimei/aimei-yangtai.jpg",@"http://www.mhome.com/assets/img/goods/aimei/aimei-weishengjian.jpg"];
    
    self.caesarArray =@[@"http://www.mhome.com/assets/img/goods/kaisa/kaisa-canting.jpg",@"http://www.mhome.com/assets/img/goods/kaisa/kaisa-zhuwo.jpg",@"http://www.mhome.com/assets/img/goods/kaisa/kaisa-ciwo.jpg",@"http://www.mhome.com/assets/img/goods/kaisa/kaisa-ertongfang.jpg",@"http://www.mhome.com//assets/img/goods/kaisa/kaisa-keting.jpg",@"http://www.mhome.com/assets/img/goods/kaisa/kaisa-shufang.jpg",@"http://www.mhome.com/assets/img/goods/kaisa/kaisa-yangtai.jpg",@"http://www.mhome.com/assets/img/goods/kaisa/kaisa-weishengjian.jpg"];
    
    self.SOHOArray =@[@"http://www.mhome.com/assets/img/goods/soho/soho-canting.jpg",@"http://www.mhome.com/assets/img/goods/soho/soho-zhuwo.jpg",@"http://www.mhome.com/assets/img/goods/soho/soho-ciwo.jpg",@"http://www.mhome.com/assets/img/goods/soho/soho-ertongfang.jpg",@"http://www.mhome.com/assets/img/goods/soho/soho-keting.jpg",@"http://www.mhome.com/assets/img/goods/soho/soho-shufang.jpg",@"http://www.mhome.com/assets/img/goods/soho/soho-yangtai.jpg",@"http://www.mhome.com/assets/img/goods/soho/soho-weishengjian.jpg"];
    self.allArray = @[self.amyArray,self.caesarArray,self.SOHOArray];
    [self setupNavBar];
}
- (void)setupNavBar {
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:18],NSForegroundColorAttributeName:[UIColor whiteColor]}];
    self.navigationController.navigationBar.translucent = NO;
    [self.navigationController.navigationBar setBackgroundImage:[UIImage getImageWithColor:[UIColor qmui_colorWithHexString:@"4bccbc"]] forBarMetrics:UIBarMetricsDefault];
    [self.navigationController.navigationBar setShadowImage:[[UIImage alloc] init]];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.array.count;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 0.01;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    return nil;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if(cell == nil){
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    }
    cell.textLabel.text = self.array[indexPath.row];
    cell.selectionStyle=UITableViewCellSelectionStyleNone;//取消cell 的点击效果
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    ProductDetailsViewController *productDetailsViewController = [[ProductDetailsViewController alloc]init];
    productDetailsViewController.productStr =self.array[indexPath.row];
    productDetailsViewController.imageArray = self.allArray[indexPath.row];
    productDetailsViewController.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:productDetailsViewController animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
